Skip to content

add support for extra_content in chat response tool calls returned by Gemini models#768

Merged
iBotPeaches merged 8 commits into
openai-php:mainfrom
leonardfischer:feature/implement-tool-extra_content
May 19, 2026
Merged

add support for extra_content in chat response tool calls returned by Gemini models#768
iBotPeaches merged 8 commits into
openai-php:mainfrom
leonardfischer:feature/implement-tool-extra_content

Conversation

@leonardfischer
Copy link
Copy Markdown
Contributor

@leonardfischer leonardfischer commented May 15, 2026

What:

  • Bug Fix
  • New Feature

Description:

This is a newer fix, based on #718 in order to fix the Gemini reponse. Gemini sends 'extra_content' when using tools in order to transfer the thought_signature. This is how it looks in the raw response:

{
  "choices": [
    {
      "finish_reason": "tool_calls",
      "index": 0,
      "message": {
        "role": "assistant",
        "tool_calls": [
          {
            "extra_content": {
              "google": {
                "thought_signature": "<token>"
              }
            },
            "function": {
              "arguments": "{}",
              "name": "function-name"
            },
            "id": "<id>",
            "type": "function"
          },
          // ...
        ]
      }
    }
  ],
  // ...

Related:

See other PR #718 - this one should take care of failed checks

closes: #718

@iBotPeaches
Copy link
Copy Markdown
Collaborator

You'll need to type the array shape of this since we are in highest PHPStan mode. Also could we get some tests to confirm OpenAI who doesn't send this doesn't have it returned? Then likewise a test for when its included that it comes back in toArray and other functions.

@leonardfischer
Copy link
Copy Markdown
Contributor Author

Hey @iBotPeaches alright - I'm on it :)

@leonardfischer
Copy link
Copy Markdown
Contributor Author

Sooo... After quite some back- and forth I managed to satisfy all linters and type-checkers (sorry, I noticed to late that this stuff can be checked locally - I'm more used to githooks that do this before committing).

I also added one more test and verified in the existing test that the new "extra_content" would not appear

@leonardfischer
Copy link
Copy Markdown
Contributor Author

Hey @iBotPeaches could you (re-) check the current state? Should I improve something more 🤔 ?

Copy link
Copy Markdown
Collaborator

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the expanse because its for another model, but on the flip side. Most folks using pure OpenAI have moved onto to Response API, so to add something that no one will notice unless using Gemini seems fine.

@iBotPeaches iBotPeaches merged commit 08437b7 into openai-php:main May 19, 2026
14 checks passed
@iBotPeaches iBotPeaches added this to the v0.20.0 milestone May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants